//
//  HomeVC.m
//  MyTest
//
//  Created by zhiyou on 16-4-12.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "HomeVC.h"
#import "SearchVC.h"
#import "WebVC.h"
#import "KindVC.h"
#import "JinRiVC.h"
#import "TuanGouVC.h"
#import "JingXuanVC.h"
#import "XiangQingVC.h"
#import "Topic.h"
#import "FirstCell.h"
#import "SecondCell.h"
#import "TopicCell.h"
#import "JingPinCell.h"
#define BASE_URL1 @"http://www.shihuo.cn/app_swoole_general/home?platform=ios&timestamp=1460365856&v=4.0.2&token=acbaf921d77a2e3efc3d2df21ee77a0d&message_time=1460364831"
#define BASE_URL2 @"http://www.shihuo.cn/app_swoole_general/homeYouhui?platform=ios&timestamp=1460365856&v=4.0.2&token=44c77ddccccb488c68698fb703b9a07b&page=1"
#define BASE_STRING @"http://www.shihuo.cn/app_swoole_general/homeYouhui?platform=ios&timestamp=1460365856&v=4.0.2&token=44c77ddccccb488c68698fb703b9a07b&page="
#define BASE_GOODS @"http://www.shihuo.cn/app2/getNewsDetail?token=90c511ef472b89c81c6c2b980e04750c&id=%@"

#define Height [UIScreen mainScreen].bounds.size.height
#define Width [UIScreen mainScreen].bounds.size.width

@interface HomeVC () <UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate>
{
    CGRect _rect;
}
@property (nonatomic, strong) NSMutableArray *bannerArr;
@property (nonatomic, strong) NSMutableArray *zoneArr;
@property (nonatomic, strong) NSMutableArray *channelArr;
@property (nonatomic, strong) NSMutableArray *topicArr;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *titleView;
@property (nonatomic, strong) UIColor *backColor;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIPageControl *pageControl;
@property (nonatomic, strong) NSTimer *timer;

@end

@implementation HomeVC
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = NO;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    _bannerArr = [[NSMutableArray alloc] init];
    _zoneArr = [[NSMutableArray alloc] init];
    _channelArr = [[NSMutableArray alloc] init];
    _topicArr = [[NSMutableArray alloc] init];
    _dataArr = [[NSMutableArray alloc] init];
    
    [self.navigationController.navigationBar addSubview:self.titleView];
    [self getDataSource];
    [self getDataArrWithURL:BASE_URL2];
    
}

#pragma mark -- UITableViewDataSource, UITableViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 3) {
        return _dataArr.count;
    }else {
        if (_zoneArr.count == 0) {
            return 0;
        }
        return 1;
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        FirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FirstCell" forIndexPath:indexPath];
        cell.contentView.backgroundColor = [UIColor grayColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        Zone *zone1 = _zoneArr[0];
        cell.titleLabel1.text = zone1.title;
        cell.subTitleLable1.text = zone1.sub_title;
        [cell.imgView1 sd_setImageWithURL:[NSURL URLWithString:zone1.img_url]];
        
        Zone *zone2 = _zoneArr[1];
        cell.titleLabel2.text = zone2.title;
        cell.subTitleLable2.text = zone2.sub_title;
        [cell.imgView2 sd_setImageWithURL:[NSURL URLWithString:zone2.img_url]];
        
        Zone *zone3 = _zoneArr[2];
        cell.titleLabel3.text = zone3.title;
        cell.subTitleLable3.text = zone3.sub_title;
        [cell.imgView3 sd_setImageWithURL:[NSURL URLWithString:zone3.img_url]];
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView:)];
        tap1.numberOfTapsRequired = 1;
        [cell.bgView addGestureRecognizer:tap1];
        
        UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView:)];
        tap2.numberOfTapsRequired = 1;
        [cell.view1 addGestureRecognizer:tap2];
        
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView:)];
        tap3.numberOfTapsRequired = 1;
        [cell.view2 addGestureRecognizer:tap3];
        
        return cell;
    } else if (indexPath.section == 1) {
        SecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SecondCell" forIndexPath:indexPath];
        cell.contentView.backgroundColor = [UIColor grayColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        Zone *zone1 = _channelArr[0];
        cell.titleLabel1.text = zone1.title;
        cell.subTitleLable1.text = zone1.sub_title;
        [cell.imgView1 sd_setImageWithURL:[NSURL URLWithString:zone1.img_url]];
        
        Zone *zone2 = _channelArr[1];
        cell.titleLabel2.text = zone2.title;
        cell.subTitleLable2.text = zone2.sub_title;
        [cell.imgView2 sd_setImageWithURL:[NSURL URLWithString:zone2.img_url]];
        
        Zone *zone3 = _channelArr[2];
        cell.titleLabel3.text = zone3.title;
        cell.subTitleLable3.text = zone3.sub_title;
        [cell.imgView3 sd_setImageWithURL:[NSURL URLWithString:zone3.img_url]];
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView1:)];
        tap1.numberOfTapsRequired = 1;
        [cell.view1 addGestureRecognizer:tap1];
        
        UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView1:)];
        tap2.numberOfTapsRequired = 1;
        [cell.view2 addGestureRecognizer:tap2];
        
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView1:)];
        tap3.numberOfTapsRequired = 1;
        [cell.view3 addGestureRecognizer:tap3];
        
        return cell;
    } else if (indexPath.section == 2){
        TopicCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        for (int i = 0; i < _topicArr.count; i++) {
            
            // 图片坐标从0开始
            UIButton * button =  [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake((Width*2/3+10)*i+10, cell.scrollView.frame.origin.y, Width*2/3, cell.frame.size.height*0.75);
            button.tag =1000+i;
            Banner *banner = _topicArr[i];
            [button sd_setBackgroundImageWithURL:[NSURL URLWithString:banner.img_url] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
            [cell.scrollView addSubview:button];
        }
        cell.scrollView.contentSize = CGSizeMake(Width*2*_topicArr.count/3, 0);
        cell.scrollView.pagingEnabled = NO;
        cell.scrollView.showsHorizontalScrollIndicator = NO;
        //cell.scrollView.showsVerticalScrollIndicator = NO;
        return cell;
    }else {
        JingPinCell *cell = [tableView dequeueReusableCellWithIdentifier:@"JingPinCell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.topic = _dataArr[indexPath.row];
        return cell;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 1 || indexPath.section == 3) {
        return 100;
    }else {
        return 150;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 6;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 3) {
        JingPinCell *cell = (JingPinCell *)[tableView cellForRowAtIndexPath:indexPath];
        Topic *topic = cell.topic;
        NSString *url = [NSString stringWithFormat:BASE_GOODS,topic.ID];
        NSLog(@"%@",url);
        
        XiangQingVC *vc = [[XiangQingVC alloc] init];
        vc.URL = url;
        [self.navigationController pushViewController:vc animated:YES];
        
    }
}
- (void)tapView:(UIGestureRecognizer *)tap
{
    UIView *bgView = [tap view];
    Zone *zone = _zoneArr[bgView.tag-100];
    KindVC *vc = [[KindVC alloc] init];
    vc.index = bgView.tag;
    vc.title = zone.title;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)tapView1:(UIGestureRecognizer *)tap
{
    UIView *bgView = [tap view];
    UIViewController *vc = nil;
    if (bgView.tag == 200) {
        vc = [[JinRiVC alloc] init];
    }else if (bgView.tag == 201) {
        vc = [[TuanGouVC alloc] init];
    }else {
        vc = [[JingXuanVC alloc] init];
    }
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)clickButton:(UIButton *)button
{
    WebVC *vc = [[WebVC alloc] init];
    Banner *topic = nil;
    switch (button.tag) {
        case 1000:
            topic = _topicArr[0];
            break;
        case 1001:
            topic = _topicArr[1];
            break;
        case 1002:
            topic = _topicArr[2];
            break;
        case 1003:
            topic = _topicArr[3];
            break;
        case 1004:
            topic = _topicArr[4];
            break;
            
        default:
            break;
    }
    vc.urlStr = topic.url;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark -- 创建cell上的scrollView

- (UIView *)setScrollView
{
    UIView *bgView = [[UIView alloc] initWithFrame:_rect];
    
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:_rect];
    for (int i = 0; i < _topicArr.count; i++) {
        
        // 图片坐标从0开始
        UIImageView * imageView=  [[UIImageView alloc] initWithFrame:CGRectMake(Width*i, 0, Width, Height/4)];
        Banner *banner = _topicArr[i];
        NSString *urlStr = [NSString stringWithFormat:@"%@",banner.img_url];
        NSURL *url = [NSURL URLWithString:urlStr];
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *image = [UIImage imageWithData:data];
        imageView.image = image;
        [scrollView addSubview:imageView];
    }
    scrollView.contentSize = CGSizeMake(Width * _topicArr.count, _rect.size.height);
    scrollView.pagingEnabled = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.delegate = self;
    scrollView.tag = 1000;
    
    [bgView addSubview:scrollView];
    return bgView;
}

#pragma mark -- 创建headerView
- (UIView *)headerView
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Width, Height/4)];
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, Width, Height/4)];
    _scrollView.tag = 2000;
    for (int i = 0; i < _bannerArr.count; i++) {
        
        // 图片坐标从0开始
        UIImageView * imageView=  [[UIImageView alloc] initWithFrame:CGRectMake(Width*i, 0, Width, Height/4)];
        Banner *banner = _bannerArr[i];
        NSString *urlStr = [NSString stringWithFormat:@"%@",banner.img_url];
        NSURL *url = [NSURL URLWithString:urlStr];
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *image = [UIImage imageWithData:data];
        imageView.image = image;
        imageView.tag = 1000+i;
        imageView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToNext:)];
        tap.numberOfTapsRequired = 1;
        [imageView addGestureRecognizer:tap];
        
        [_scrollView addSubview:imageView];
    }
    _scrollView.contentSize = CGSizeMake(Width * _bannerArr.count, 120);
    _scrollView.pagingEnabled = YES;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    _scrollView.delegate = self;
    
    
    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, Height/4-20, Width, 20)];
    
    _pageControl.numberOfPages = _bannerArr.count;
    _pageControl.pageIndicatorTintColor = [UIColor whiteColor];
    _pageControl.currentPageIndicatorTintColor = [UIColor redColor];
    [_pageControl addTarget:self action:@selector(pageControlChanged) forControlEvents:UIControlEventValueChanged];
    
    [headerView addSubview:_scrollView];
    [headerView addSubview:_pageControl];
    
    _timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(changeImage) userInfo:nil repeats:YES];
    
    return headerView;
}
- (void)goToNext:(UITapGestureRecognizer *)tap
{
    UIView *imgView = [tap view];
    
    WebVC *vc = [[WebVC alloc] init];
    Banner *banner = nil;
    switch (imgView.tag) {
        case 1000:
            banner = _bannerArr[0];
            break;
        case 1001:
            banner = _bannerArr[1];
            break;
        case 1002:
            banner = _bannerArr[2];
            break;
        case 1003:
            banner = _bannerArr[3];
            break;
        case 1004:
            banner = _bannerArr[4];
            break;
        default:
            break;
    }
    vc.urlStr = banner.url;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)pageControlChanged
{
    [_scrollView setContentOffset:CGPointMake(_pageControl.currentPage *Width, 0) animated:YES];
    [_timer invalidate];
    _timer = nil;
}

- (void)changeImage
{
    // 定义一个静态变量,代表方向
    static int direction = 1;
    if (_scrollView.contentOffset.x == 0)
    {
        direction = 1;
    }
    if (_scrollView.contentOffset.x == Width*(_bannerArr.count-1))
    {
        direction = -1;
    }
    // 设置滚动视图的偏移量,带动画
    [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x+Width*direction, 0) animated:YES];
}

#pragma mark -- UIScrollViewDelegate
// 将要开始拖拽
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    // 开始拖拽时,把定时器关闭
    [_timer invalidate];
    _timer = nil;
}

//已经结束拖拽
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    
}

// 将要开始减速
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    
}

// 已经结束减速
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    float offSet_x = scrollView.contentOffset.x;
    _pageControl.currentPage = offSet_x/Width;
    // 结束减速把定时器重新开启
    if (_timer == nil) {
        _timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(changeImage) userInfo:nil repeats:YES];
    }
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
    if (_timer == nil)
    {
        _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeImage) userInfo:nil repeats:YES];
    }
    
    float offSet_x = scrollView.contentOffset.x;
    _pageControl.currentPage = offSet_x/Width;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if(self.tableView.contentOffset.y<-20) {
    
        [self.titleView setHidden:YES];
        
    }else if(self.tableView.contentOffset.y<700){
        
        [self.titleView setHidden:NO];
        self.titleView.backgroundColor=[UIColor colorWithRed:0.9 green:0 blue:0 alpha:self.tableView.contentOffset.y / 1000];
    }else
    {
        [self.titleView setHidden:NO];
        self.titleView.backgroundColor=[UIColor colorWithRed:0.9 green:0 blue:0 alpha:1];
    }
}
#pragma mark -- 获得数据源
- (void)getDataSource
{
    _bannerArr = [[NSMutableArray alloc] init];
    _zoneArr = [[NSMutableArray alloc] init];
    _channelArr = [[NSMutableArray alloc] init];
    _topicArr = [[NSMutableArray alloc] init];
    
    [MyRequest getWithURL:BASE_URL1 parameters:nil success:^(NSDictionary *dic) {
        
        NSDictionary *dictionary = [dic objectForKey:@"data"];
        
        NSArray *arr1 = [dictionary objectForKey:@"banner"];
        self.bannerArr = [MyTools getBannerWithArray:arr1];
        
        NSArray *arr2 = [dictionary objectForKey:@"topic"];
        self.topicArr = [MyTools getBannerWithArray:arr2];
        
        NSArray *arr3 = [dictionary objectForKey:@"zone"];
        self.zoneArr = [MyTools getZoneWithArray:arr3];
        
        NSArray *arr4 = [dictionary objectForKey:@"channel"];
        self.channelArr = [MyTools getZoneWithArray:arr4];
        
       [self.view addSubview:self.tableView];
        
    } fail:^(NSError *error) {
        NSLog(@">>>>%@",error);
    }];
}

- (void)getDataArrWithURL:(NSString *)URL
{
    
    [MyRequest getWithURL:URL parameters:nil success:^(NSDictionary *dic) {
        NSArray *arr = [dic objectForKey:@"data"];
        for (NSDictionary *dic in arr) {
            Topic *topic = [[Topic alloc] initWithDictonary:dic];
            [_dataArr addObject:topic];
        }
        [_tableView reloadData];
    } fail:^(NSError *error) {
        NSLog(@">>>>%@",error);
    }];
}

#pragma mark -- 设置导航的titleView
- (UIView *)titleView
{
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    //去掉底部线条
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    if (_titleView == nil) {
        _titleView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, Width, 64)];
        UIColor *backColor = [UIColor redColor];
        _titleView.backgroundColor = [backColor colorWithAlphaComponent:0];
        
        self.backColor = backColor;
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        button.titleLabel.textAlignment = NSTextAlignmentLeft;
        UIImage * buttonImage = [UIImage  imageNamed:@"icon_search"];
        
        UIImage * stretchableButtonImage = [buttonImage  stretchableImageWithLeftCapWidth:8  topCapHeight:8];
        
        [button setImage:stretchableButtonImage forState:UIControlStateNormal];
        [button setTitle:@"搜索商品" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        button.clipsToBounds = YES;
        button.layer.cornerRadius = 5;
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
        
        [button setBackgroundColor:[UIColor whiteColor]];
        [_titleView addSubview:button];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(10);
            make.right.offset(-50);
            make.bottom.equalTo(_titleView.mas_bottom).offset(-10);
            make.height.offset(25);
        }];
        
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [button1 setTitle:@"消息" forState:UIControlStateNormal];
        button1.titleLabel.font = [UIFont systemFontOfSize:15];
        [button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        button1.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
        [button1 addTarget:self action:@selector(btnClick1) forControlEvents:UIControlEventTouchUpInside];
        [_titleView addSubview:button1];
        
        [button1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-10);
            make.height.offset(50);
            make.bottom.equalTo(_titleView.mas_bottom).offset(-10);
            make.width.offset(30);
        }];
    }
    return _titleView;
}

- (void)btnClick {
    SearchVC *vc = [[SearchVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)btnClick1 {
    
    NewsVC *vc = [[NewsVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark -- 初始化tableView

- (UITableView *)tableView
{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Width, Height-49) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        //[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        [_tableView registerClass:[FirstCell class] forCellReuseIdentifier:@"FirstCell"];
        [_tableView registerClass:[SecondCell class] forCellReuseIdentifier:@"SecondCell"];
        [_tableView registerClass:[TopicCell class] forCellReuseIdentifier:@"TopicCell"];
        [_tableView registerClass:[JingPinCell class] forCellReuseIdentifier:@"JingPinCell"];
         self.tableView.tableHeaderView = [self headerView];
    }
    [self refresh];
    return _tableView;
}

#pragma mark -- 刷新加载
- (void)refresh
{
    __block HomeVC *mySelf = self;
    
    [_tableView addPullToRefreshWithActionHandler:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [mySelf.tableView.pullToRefreshView stopAnimating];
            [mySelf getDataSource];
        });
    }];
    
    [_tableView addInfiniteScrollingWithActionHandler:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [mySelf.tableView.infiniteScrollingView stopAnimating];
            static int count = 2;
            [mySelf getDataArrWithURL:[NSString stringWithFormat:@"%@%d",BASE_STRING,count]];
            count ++;
        });
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
